package com.jcl.recruit.resume.logic;

import com.jcl.core.utils.CollectionUtils;
import com.jcl.recruit.resume.mapper.ResumeProjectMapper;
import com.jcl.recruit.resume.model.ResumeProject;
import com.jcl.recruit.resume.model.ResumeWork;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ResumeProjectLogic
 * @Description TODO
 * @Author yyliu
 * @Date 2018/10/31 11:22
 * @Version 1.0
 **/
@Component
public class ResumeProjectLogic implements ResumeProjectMapper {

    @Autowired
    private ResumeProjectMapper resumeProjectMapper;

    public Map<Integer, List<ResumeProject>> findListByResumeMap(String corpCode, List<Integer> resumeIds){

        Map<Integer, List<ResumeProject>> dataMap = new HashMap<>();
        List<ResumeProject> list = resumeProjectMapper.findListByResumeIds(corpCode, resumeIds);
        if(CollectionUtils.isNotEmpty(list)){
            for(ResumeProject entity: list){
                List<ResumeProject> entityList = dataMap.get(entity.getResumeId());
                if(null == entityList){
                    entityList = new ArrayList<>();
                    dataMap.put(entity.getResumeId(), entityList);
                }
                entityList.add(entity);
            }
        }
        return dataMap;
    }

    @Override
    public List<ResumeProject> findListByResumeIds(String corpCode, List<Integer> resumeIds) {
        return resumeProjectMapper.findListByResumeIds(corpCode, resumeIds);
    }

    @Override
    public List<ResumeProject> findListByResumeId(String corpCode, Integer resumeId) {
        return resumeProjectMapper.findListByResumeId(corpCode, resumeId);
    }

    @Override
    public List<Map<String, Object>> findObjListByResumeId(String corpCode, Integer resumeId) {
        return resumeProjectMapper.findObjListByResumeId(corpCode, resumeId);
    }

    @Override
    public int isExitEntity(ResumeProject entity) {
        return resumeProjectMapper.isExitEntity(entity);
    }

    @Override
    public int batchInsert(List<ResumeProject> list) {
        return resumeProjectMapper.batchInsert(list);
    }

    @Override
    public int insert(ResumeProject entity) {
        return resumeProjectMapper.insert(entity);
    }

    @Override
    public int updateByPrimaryKey(ResumeProject entity) {
        return resumeProjectMapper.updateByPrimaryKey(entity);
    }

    @Override
    public int deleteById(Integer id) {
        return resumeProjectMapper.deleteById(id);
    }

    @Override
    public int batchDeleteByResumeIds(String corpCode, List<Integer> resumeIds) {
        return resumeProjectMapper.batchDeleteByResumeIds(corpCode, resumeIds);
    }
}
